//
//  TitleButton.swift
//  weibo-new
//
//  Created by mac on 2017/3/27.
//  Copyright © 2017年 gjx. All rights reserved.
//

import UIKit

class TitleButton: UIButton {

    init(title: String, imgName: String, selectedImgName: String) {
        super.init(frame: CGRect.zero)
        
        setTitleColor(UIColor.black, for: .normal)
        setTitle(title, for: .normal)
        titleLabel?.font = UIFont.boldSystemFont(ofSize: 17)
        setImage(UIImage(named: imgName), for: .normal)
        setImage(UIImage(named: selectedImgName), for: .selected)
        sizeToFit()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        
        titleLabel?.frame.origin.x = 0
        imageView?.frame.origin.x = titleLabel!.frame.size.width + 5
    }
}
